﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YArchitech.Revit.MEP.Opening
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdClearOpeningTag : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string messages, ElementSet elements)
		{
			UIApplication application = cmdData.Application;
			Application application2 = application.Application;
			Document document = application.ActiveUIDocument.Document;
			IList<Element> list = new FilteredElementCollector(document).OfClass(typeof(FamilyInstance)).ToElements();
			Transaction transaction = new Transaction(document, "ClearTag");
			transaction.Start();
			foreach (Element element in list)
			{
				if ((element as FamilyInstance).Symbol.Name == "楼板开洞标记" || (element as FamilyInstance).Symbol.Name == "墙开洞标记")
				{
					document.Delete(element.Id);
				}
			}
			transaction.Commit();
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
